package cn.com.cifi.mars.web.action.projectConsole;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import cn.com.cifi.mars.bean.vo.common.CommonVo;
import cn.com.cifi.mars.bean.vo.sys.rsp.StagesVo;
import cn.com.cifi.mars.bean.vo.workBench.ProjectNewDynamicVo;
import cn.com.cifi.mars.bean.vo.workBench.ProjectToDoVo;
import cn.com.cifi.mars.bean.vo.workBench.SysToDoVo;
import cn.com.cifi.mars.common.base.BaseAction;
import cn.com.cifi.mars.common.bean.R;
import cn.com.cifi.mars.entity.common.IdmUser;
import cn.com.cifi.mars.service.WorkBenchService;

/**
 * 工作台
 * @author Administrator
 *
 */
@RestController
public class WorkBenchController extends BaseAction implements IWorkBenchController {

	@Autowired
	private WorkBenchService workBenchService;
	
	/**
	 * 项目分期下拉框
	 */
	@Override
	public R<List<StagesVo>> getStages(String apiVersion, String projectId) {
		return ok(workBenchService.queryStagesList(projectId));
	}

	/**
	 * 显示门户待办类型(下拉框)
	 */
	@Override
	public R<List<CommonVo>> getTodoType(String apiVersion) {
		return ok(workBenchService.getTodoType());
	}

	/**
	 * 项目待办提醒分页
	 */
	@Override
	public R<ProjectToDoVo> getPorjectToDoPage(String apiVersion, String current, String pageSize, String projectId,
			String stagesId, String typeId, String state) {
		return ok(workBenchService.getPorjectToDoPage(current,pageSize,projectId,stagesId,typeId,state));
	}

	/**
	 * 系统待办提醒分页
	 */
	@Override
	public R<SysToDoVo> getSysToDoPage(String apiVersion, String current, String pageSize, String nameOrCode,
			String typeId, String state) {
		IdmUser user = getOperator();
		return ok(workBenchService.getSysToDoPage(current, pageSize, nameOrCode, typeId, state, user.getUsername()));
	}


	/**
	 * 项目最新动态
	 */
	@Override
	public R<ProjectNewDynamicVo> getProjectNewDynamicPage(String apiVersion, String current, String pageSize,
			String projectId, String stagesId, String eventId, String moduleTypeId, String versionType,
			String operationBy, String begin, String end) {
		return ok(workBenchService.getProjectNewDynamicPage(current,pageSize,projectId,stagesId,
				eventId,moduleTypeId,versionType,operationBy, StringUtils.isBlank(begin) ? null : begin.substring(0,10), StringUtils.isBlank(end) ? null : end.substring(0,10)));
	}

	/**
	 * 事件(下拉框)
	 */
	@Override
	public R<List<CommonVo>> getEvent(String apiVersion) {
		return ok(workBenchService.getEvent());
	}

	/**
	 * 业务类型(下拉框)
	 */
	@Override
	public R<List<CommonVo>> getBusinessType(String apiVersion) {
		return ok(workBenchService.getBusinessType());
	}

	/**
	 * 版本类型(下拉框)
	 */
	@Override
	public R<List<CommonVo>> getVersionType(String apiVersion) {
		return ok(workBenchService.getVersionType());
	}

	/**
	 * 操作人(下拉框)
	 */
	@Override
	public R<List<CommonVo>> getOperationBy(String apiVersion,String projectId) {
		return ok(workBenchService.getOperationBy(projectId));
	}

}
